# koroFileHeader at Yungoal acer
# Create: 2022-10-10 10:55:23
# LastEdit: 2022-10-10 11:53:12
"""项目管理 模型"""
__author__ = '749B'

from django.db import models

from .validators import validate_azure_id, validate_number_only, validate_email_list

class Subscriptions(models.Model):
    guid = models.CharField(max_length=128, validators=[validate_azure_id], verbose_name='订阅 Guid', unique=True)
    short_id = models.CharField(max_length=16, validators=[validate_number_only], verbose_name='订阅 Id')        
    name = models.CharField(max_length=128, verbose_name='订阅名称')
    # 预算告警相关
    usage_budget = models.DecimalField(max_digits=12, decimal_places=2, verbose_name='预算', default=0)
    usage_threshold = models.SmallIntegerField(verbose_name='告警阈值', default=90)
    usage_alarm = models.BooleanField(verbose_name='开启告警', default=True)
    email = models.CharField(
        max_length=1024, verbose_name='通知人邮箱', validators=[validate_email_list], default='', blank=True,
        help_text="多个邮箱用分号分隔")
    
    def __str__(self):
        return self.name

    class Meta:
        verbose_name = '订阅'
        verbose_name_plural = '订阅表'

